//    Copyright (C) Kherty.  All rights reserved.
using System.Windows;
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Internals;

namespace OpenLS.Drawing
{
    public class AdjPoint2D : IOfficeXmlSerializableAs
    {
        private string x; //\\

        private string y; //\\

        public string X
        {
            get { return x; }
            set { x = value; }
        }

        public string Y
        {
            get { return y; }
            set { y = value; }
        }

        #region IOfficeXmlSerializableAs Members

        void IOfficeXmlSerializableAs.ReadXmlAs(string name, ReadContext context)
        {
            using (var c = context.Read(name))
            {
                X = c.GetString("x");
                Y = c.GetString("y");
            }
        }

        void IOfficeXmlSerializableAs.WriteXmlAs(string name, WriteContext context)
        {
            using (WriteContext c = context.Write(name))
            {
                c.SetString("x", X);
                c.SetString("y", Y);
            }
        }

        #endregion

        internal Point ToPoint()
        {
            return new Point(EmuConverter.FromEmu(long.Parse(X)),
                             EmuConverter.FromEmu(long.Parse(Y)));
        }
    }
}